package mr.ali.video.web.controller;


import com.github.pagehelper.PageInfo;
import mr.ali.video.web.Exception.R;
import mr.ali.video.web.mapper.CollectionPlayMapper;
import mr.ali.video.web.model.Collection;
import mr.ali.video.web.model.CollectionPlay;
import mr.ali.video.web.service.ICollectionPlayService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Mr-ali
 * @since 2025-08-03
 */
@RestController
@RequestMapping("/web/collectionPlay")
public class CollectionPlayController {
    @Resource
    private ICollectionPlayService collectionPlayService;

    @Resource
    private CollectionPlayMapper collectionPlayMapper;

    @GetMapping("/select")
    public PageInfo<CollectionPlay> select(Integer pageNum, Integer pageSize) {
        return collectionPlayService.getCollectionPlay(pageNum, 20);
    }


    @GetMapping("/update/displayed")
    public R<Integer> updateDisplayed(Integer id, Integer displayed) {
        return R.ok(collectionPlayService.updateDisplayed(id, displayed));
    }

    @GetMapping("/deleteById")
    public R<Integer> deleteById(Integer id) {
        return R.ok(collectionPlayService.deleteById(id));
    }

    @GetMapping("/selectById")
    public R<Collection> selectById(Integer id) {
        return R.ok(collectionPlayService.selectById(id));
    }

    @GetMapping("/insert")
    public R<Integer> insert(CollectionPlay collection) {
        return R.ok(collectionPlayService.insert(collection));
    }
    @GetMapping("/selectByTypeId")
    public Integer selectByTypeId() {
        return collectionPlayMapper.CountByTypeId();
    }
}
